#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string>
#include <stack>
#include <set>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;
string s;
ll num[1010];
ll cnt;

ll f(ll l,ll r){
    ll sum=0;
    l++;
    while(l<r){
        if(s[l]!='0')break;
        l++;
    }
    for(ll i=l;i<r;i++){
        sum=sum*10+(s[i]-'0');
    }
    return sum;
}

int main()
{
    IOS;
    while(cin>>s){
    s="#"+s;
    ll len=s.length();
    ll l=0,r;
    cnt=0;
    for(ll i=1;i<len;i++){
        if(s[i]=='5'){
            r=i;
            if(r>l+1)
                num[cnt++]=f(l,r);
            l=i;
        }
    }   
    //特判末尾 
    if(l!=len-1){
        num[cnt++]=f(l,len);
    }
    sort(num,num+cnt);
    cout<<num[0];
    for(ll i=1;i<cnt;i++){
        cout<<" "<<num[i];
    }
    cout<<endl;
    }
    getchar();
    getchar();
    return 0;
}
